package com.kedi.evergreenschoolcenter.read.dao.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 
 *
 * @author: 		陈辽逊
 * @date: 			2019/7/13 10:29
 */
@Mapper
public interface ReadOnlineClassMapper {
	
	/**
	 * 				 获取在线课堂的所有状态
	 * @return		 calss
	 */
	@Select("SELECT calss FROM  onlineclass")
	List<Map<String, Object>> calss();		
	
	/**				获取书法总条数
	 * @return		getsfid
	 */
	@Select("SELECT COUNT(id) as total_size ,* FROM onlineclass WHERE title = '书法' "
			+ "ORDER BY bed_id ASC "
			+ "LIMIT  #{page},#{limit};")
	int getsfid(@Param("page")int page,@Param("limit")int limit);
	/**
	 * 				根据书法id返回报名电话
	 * @param id
	 * @return		getsfphone
	 */
	@Select("SELECT phone FROM  onlineclass WHERE id = (#{id}) AND title = '书法'")
	int getsfphone(@Param("id")int id);		
	
	
	/**				获取舞蹈总条数
	 * @return		getwdid
	 */
	@Select("SELECT COUNT(id) as total_size ,* FROM onlineclass WHERE title = '舞蹈' "
			+ "ORDER BY bed_id ASC "
			+ "LIMIT  #{page},#{limit};")
	int getwdid(@Param("page")int page,@Param("limit")int limit);
	
	/**
	 * 				根据舞蹈id返回报名电话
	 * @param id
	 * @return		getwdphone
	 */
	@Select("SELECT phone FROM  onlineclass WHERE id = (#{id}) AND title = '舞蹈'")
	int getwdphone(@Param("id")int id);
	
	/**				获取手工艺总条数
	 * @return		getsgyid
	 */
	@Select("SELECT COUNT(id) as total_size ,* FROM onlineclass WHERE title = '手工艺' "
			+ "ORDER BY bed_id ASC "
			+ "LIMIT  #{page},#{limit};")
	int getsgyid(@Param("page")int page,@Param("limit")int limit);
	
	/**
	 * 				根据手工艺id返回报名电话
	 * @param id
	 * @return		getsgyphone
	 */
	@Select("SELECT phone FROM  onlineclass WHERE id = (#{id}) AND title = '手工艺'")
	int getsgyphone(@Param("id")int id);
	
	/**				获取数码应用总条数
	 * @return		getsmyyid
	 */
	@Select("SELECT COUNT(id) as total_size ,* FROM onlineclass WHERE title = '数码应用' "
			+ "ORDER BY bed_id ASC "
			+ "LIMIT  #{page},#{limit};")
	int getsmyyid(@Param("page")int page,@Param("limit")int limit);
	
	/**
	 * 				根据数码应用id返回报名电话
	 * @param id
	 * @return		getsmyyphone
	 */
	@Select("SELECT phone FROM  onlineclass WHERE id = (#{id}) AND title = '数码应用'")
	int getsmyyphone(@Param("id")int id);
	
	/**
	 * 				 根据类型获取在线课堂所有数据
	 * @param		 cal
	 * @return		 online
	 */
	@Select("SELECT c.p_user_id,c.title,c.content,"
			+ "c.imageaddress,c.praisenum,c.collectnum,"
			+ "CONVERT (c.calss  USING utf8) as calss,"
			+ "DATE_FORMAT(c.pulishtime, '%Y-%m-%d') as pulishtime,"
			+ "s.*"
			+ "FROM onlineclass c "
			+ "LEFT JOIN onlinesource s "
			+ "on c.id = s.id "
			+ "WHERE title = (#{title})")
	List<Map<String, Object>> online(@Param("title") String title);	
	
}
